home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / exec / addtolis.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  916 b   |  42 lines

  1. /*
  2. \funcref{addtolist}{VAR\_ addtolist (\params)}
  3.     {
  4.         {VAR\_} {v} {variable holding list to add to}
  5.         {char} {*s} {string to add to list}
  6.     }
  7.     {variable holding expanded list}
  8.     {initvar(), xrealloc(), xstrdup()}
  9.     {inlist(), copylist()}
  10.     {addtolis.c}
  11.     {
  12.         This function adds string {\em s} to the list of variable {\em v}. The
  13.         same variable is returned.
  14.  
  15.         Variable {\em v} is initialized (if necessary) to accomodate an
  16.         intermediate memory allocation struct and the new element.
  17.     }
  18. */
  19.  
  20. #include "icm-exec.h"
  21.  
  22. VAR_ addtolist (v, s)
  23. VAR_ v;
  24. char *s;
  25. {
  26.     register LIST_
  27.         *list;
  28.  
  29.     v = initvar (v);
  30.  
  31.     if (! s || ! *s)
  32.         return (v);
  33.  
  34.     list = &(v.vu.i->ls.list);
  35.     list->element =
  36.         xrealloc (list->element, (list->size + 1) * sizeof (char *));
  37.     list->element[list->size] = xstrdup (s);
  38.     list->size++;
  39.  
  40.     return (v);
  41. }
  42.